fix flake8 linting errors and add lint check in CI#143
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a GitHub Actions workflow to lint the repository’s Python code with isort and flake8, and applies broad formatting/import cleanups across the codebase to address existing flake8 issues.
Changes:
- Added a CI workflow that runs
isortandflake8on pushes/PRs affecting*.pyfiles. - Reformatted multiple modules (Black-style wrapping) and reorganized imports to reduce lint violations.
- Updated a few tests and utility scripts to comply with linting rules (e.g., line length, unused imports).
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
tests/unit/test_smoke.py |
Marks unused import with noqa to satisfy flake8. |
tests/test_mps_device.py |
Formatting changes; introduces a regression in memory allocation test and unused locals. |
flexynesis/modules.py |
Import cleanup and formatting adjustments. |
flexynesis/models/triplet_encoder.py |
Import/format refactor; introduces critical bugs in Captum attribution path. |
flexynesis/models/supervised_vae.py |
Import and formatting cleanups for lint compliance. |
flexynesis/models/gnn_early.py |
Import/format updates; minor naming mismatch in helper. |
flexynesis/models/direct_pred.py |
Import and formatting cleanups for lint compliance. |
flexynesis/models/crossmodal_pred.py |
Import and formatting cleanups for lint compliance. |
flexynesis/models/__init__.py |
Reorders imports and formats __all__. |
flexynesis/main.py |
Large formatting refactor; introduces a hard-to-read/incorrect early-stop condition expression. |
flexynesis/inference.py |
Formatting and minor refactors to imports / long lines. |
flexynesis/generate_coexpression_network.py |
Formatting refactor; exposes an option that isn’t actually implemented. |
flexynesis/feature_selection.py |
Import ordering and formatting updates. |
flexynesis/config.py |
Formatting and consistent quoting in search-space definitions. |
flexynesis/__init__.py |
Formatting and import ordering updates for lazy import wrapper. |
.github/workflows/lint.yml |
New workflow to run isort + flake8 in CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ), | ||
| n_steps=steps_or_samples, | ||
| ) | ||
| attributions = attributions.split(layer_sizes, dim=3) | ||
| elif method == "GradientShape": | ||
| attributions = explainer.attribute( | ||
| input_data, | ||
| baseline, | ||
| additional_forward_args=( | ||
| layer_sizes, | ||
| target_var, | ||
| steps_or_samples, | ||
| ), | ||
| n_samples=steps_or_samples, | ||
| ) | ||
| attributions = attributions.split(layer_sizes, dim=3) |
There was a problem hiding this comment.
Typo in method dispatch: branch checks elif method == "GradientShape" but the supported method name elsewhere is "GradientShap". With method="GradientShap", neither branch runs in the num_class == 1 case, leaving attributions undefined. Rename the branch to "GradientShap" (and ensure both numerical + categorical paths handle it).
There was a problem hiding this comment.
It is also not related to the linting fixes of this PR, but it looks valid to me.
Should I change it to "Gradientshap"?
There was a problem hiding this comment.
yes, that is a typo/bug, should be fixed.
| def generate_coexpression_network( | ||
| input_file, | ||
| output_file, | ||
| method='spearman', | ||
| method="spearman", | ||
| min_correlation=0.3, | ||
| top_k=10, | ||
| remove_self_loops=True, | ||
| remove_duplicates=True | ||
| remove_duplicates=True, | ||
| ): |
There was a problem hiding this comment.
remove_self_loops is exposed in generate_coexpression_network(...) but is never used; self-correlations are always removed in build_network via gene_corr[global_idx] = 0. Either implement the flag (conditionally keep self-loops) or remove the parameter to avoid a non-functional API option.
There was a problem hiding this comment.
It is also not related to the linting fixes of this PR, but it looks valid to me.
Should I remove the arg?
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Looks like this file can not be accessed? |
|
Hi @borauyar, Can we replace |
Hey @nilchia, I don't mind replacing it. I had to change it because there was a problem with the previous MSK dataset. When you download it, the files are just empty. That was breaking the tutorial. If you'd like to change it to something else that demonstrates the cbioportal feature (with at least 2 data modalities), I don't mind changing to something else. |
This comment was marked as resolved.
This comment was marked as resolved.
…loaded and unzipped
This comment was marked as resolved.
This comment was marked as resolved.
|
|
||
| def get_cbioportal_data(self, study_id, files=None): | ||
| archive_path = self.download_study_archive() | ||
| study_dir = self.extract_archive(archive_path) |
There was a problem hiding this comment.
This was the culprit.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@nilchia Thank you! Looks like a lot of work :) It took me a while to just go through. |
This PR adds a new GitHub Actions workflow to automatically lint Python scripts using
isortandflake8on pushes and pull requests.It also fixes current lint errors from flake8.
I ran black for reformating, flake8, and isort file lint checkin.
Each error is fixed in a commit.
The lint error of long lines is fixed with claude.